import lzRquest from '@/service'
import { IDataType } from '../types'
import { IAccount } from './types'

enum LoginAPI {
  AccountLogin = '/login', // 用户登录
  LoginUserInfo = '/users/', // 查询某个用户
  UserMenus = '/role/' // 查询角色菜单树
}

export function accountLoginRequest(account: IAccount) {
  return lzRquest.post<IDataType>({
    url: LoginAPI.AccountLogin,
    data: account,
    showLoading: true
  })
}

export function requestUserInfoById(id: number) {
  return lzRquest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id,
  })
}

export function requestUserMenusByRoleId(roleId: number) {
  return lzRquest.get<IDataType>({
    url: LoginAPI.UserMenus + roleId + '/menu',
  })
}
